import time

from xinan_ui.proxy.base_page import PageHandle
from xinan_ui.tools.read_yml_xn import ReadYaml

data_eles = ReadYaml(r'D:\testLi\PythonWork\xinan_ui\config\jdzapp.yml').read_yaml()['融资买入']

class RzBuyJdz(PageHandle):
    def __init__(self,driver):
        self.driver=driver
        super().__init__(self.driver)

    def rz_jdz(self,code,amount):
        #点击融资买入入口
        self.click_button(data_eles[0]['融资买入入口'])
        time.sleep(1)
        #点击股票代码输入框
        self.click_button(data_eles[1]['股票代码输入框'])
        time.sleep(1)
        #输入股票代码
        self.input_element(data_eles[1]['股票代码输入框'],code)
        time.sleep(1)
        #出现不在融资标记池弹窗
        try:
            # 点击系统信息确定按钮
            self.click_button(data_eles[5]['系统信息确定按钮'])
            time.sleep(2)
            #输入价格
            self.input_element(data_eles[8]['价格输入框'],19.2)
            time.sleep(1)
        except:
            print('在融资标记池里')
        #输入数量输入框
        self.input_element(data_eles[2]['数量输入框'],amount)
        time.sleep(1)
        #点击融资买入按钮
        self.click_button(data_eles[3]['融资买入按钮'])
        time.sleep(3)
        #点击确认买入确定按钮
        self.click_button(data_eles[4]['确认买入确定按钮'])
        time.sleep(2)
        #获取委托文案
        # data=self.get_text(data_eles[6]['委托信息文案'])
        # time.sleep(3)
        #点击系统信息确定按钮
        self.click_button(data_eles[5]['系统信息确定按钮'])
        time.sleep(2)
        data = self.get_text(data_eles[6]['委托信息文案'])

        time.sleep(1)
        self.click_button(data_eles[5]['系统信息确定按钮'])
        time.sleep(2)
        # 返回上级
        self.click_button(data_eles[7]['返回上级'])
        return data
